/**
 * @param {string} s
 * @return {string}
 */
 var longestPalindrome = function(s) {
  if (!s) return ''
  let sArr = s.split('')
  let max = 0
  let maxStr = ''
  let currStr = ''
  let num = 1
  const getPrevNext = (i, num) => {
      if ( sArr[i + num] === s[i - num] && sArr[i + num] && sArr[i - num]) {
          currStr = s[i - num] + currStr + s[i + num]
          getPrevNext(i, num + 1)
          return
      }
      if ( sArr[i + num] ==  sArr[i + num - 1] ) {
          currStr = currStr + s[i + 1]
      }
  }
  const getMaxStr = (s, i) => {
      getPrevNext(i, num)
  }
  sArr.forEach((v, i) => {
      currStr = v
      getPrevNext(i, 1)
      if (currStr.length > maxStr.length) {
          maxStr =  currStr
      }
  })
  return maxStr
};